package com.wu.deadQueue;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import com.wu.rabbitmq.utils.RabbitMQUtils;
import lombok.SneakyThrows;

import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

/**
 * @program: RabbitMQ-Study
 * @author: 吴磊
 * @create: 2021-12-17 17:04
 * 死信队列实战
 * 消费者1
 */
public class Consumer02 {
    //死信队列的名称
    private static final String DEAD_QUEUE = "dead_queue";

    @SneakyThrows
    public static void main(String[] args) {
        Channel channel = RabbitMQUtils.getChannel();
        System.out.println("Consumer02等待接收消息......");
        DeliverCallback deliverCallback = (consumerTag, message) -> System.out.println("Consumer02接收消息：" + new String(message.getBody(), StandardCharsets.UTF_8));
        channel.basicConsume(DEAD_QUEUE, true, deliverCallback, consumerTag -> {
        });

    }

}
